<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="归还单号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="归还日期" prop="FBILLCREDATE">
            <el-date-picker v-model="dataForm.FBILLCREDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="归还状态">
              <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

         <el-col :span="8">
          <el-form-item label="研学单号" prop="FSRCNO">
            <el-input v-model="dataForm.FSRCNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="学校名称">
              <el-select v-model="dataForm.FHOME" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="课程名称">
              <el-select v-model="dataForm.FCATNAME" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

         <el-col :span="8">
          <el-form-item label="供应商" prop="FSUPNAME">
            <el-input v-model="dataForm.FSUPNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="经办人员" prop="FUSER">
            <el-input v-model="dataForm.FUSER"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="设备数量" prop="FNUM">
            <el-input v-model="dataForm.FNUM"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="租赁费用" prop="FMONEY">
            <el-input v-model="dataForm.FMONEY"   />
          </el-form-item>
        </el-col>

        <el-col :span="16">
          <el-form-item label="租赁备注" prop="FMEMO">
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>
       
        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加</el-button> -->
            <el-button type="primary" :loading="loading" @click="closePage">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">

      <el-tab-pane label="设备列表" name="first">
        <el-table :data="list" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>   
          <el-table-column prop="FTYPE" label="设备类型" ></el-table-column>
          <el-table-column prop="FCATNO" label="设备编号"></el-table-column>
          <el-table-column prop="FCATNAME" label="设备名称" ></el-table-column>
          <el-table-column prop="FSPEC" label="型号" ></el-table-column>
          <el-table-column prop="FBRAND" label="品牌" ></el-table-column>
          <el-table-column prop="FNUM" label="数量" ></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>
      
      <el-tab-pane label="设备序列号" name="third">
        <el-table :data="list2" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FTYPE" label="设备类型" ></el-table-column>
          <el-table-column prop="FCATNO" label="设备编号"></el-table-column>
          <el-table-column prop="FCATNAME" label="设备名称" ></el-table-column>
          <el-table-column prop="FSPEC" label="型号" ></el-table-column>
          <el-table-column prop="FNUM" label="序列号" ></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>


    </el-tabs>
  </template>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'first',
        title: "新增",
        insertorupdate: true,
        dataForm: {
            FBILLNO: "G241130001", 
            FSRCNO: "K241130001", 
            FBILLCREDATE:"2024-11-29",
            FHOME:"闵行春申小学",
            FCATNAME:"上海博物馆研学",
            FUSER:"秦始皇",
            FNUM:200,
            FMONEY:25000,
            FSUPNAME:"上海高科后勤服务有限公司",
            FMEMO: "每天执行并上报",
            FCHECKUSE: "",
            FCHECKDATE: "",
            FBILLTYPE:"日巡查",
            FBILLSTATE: "已确认"
        },
        rules: {
          FNOTE:[
            { required: true, message: '请输入巡检说明', trigger: 'blur' },
          ],
        },
        list: [{   "FENTRYID":1,
                    "FTYPE": "手环",
                    "FCATNO":"100001",
                    "FCATNAME": "智能手环",
                    "FBRAND": "标准",
                    "FSPEC":"500-D",
                    "FNUM":100
                  },
                  { "FENTRYID":2,
                    "FTYPE": "摄像机",
                    "FCATNO":"100002",
                    "FCATNAME": "佩戴式摄像机",
                    "FBRAND": "标准",
                    "FSPEC":"700-L",
                    "FNUM":100
                  }],
        list2: [{   "FENTRYID":1,
                    "FTYPE": "手环",
                    "FCATNO":"100001",
                    "FCATNAME": "智能手环",
                    "FBRAND": "标准",
                    "FSPEC":"500-D",
                    "FNUM":"SH25-01-0002",
                  },
                  { "FENTRYID":2,
                    "FTYPE": "手环",
                    "FCATNO":"100001",
                    "FCATNAME": "智能手环",
                    "FBRAND": "标准",
                    "FSPEC":"500-D",
                    "FNUM":"SH25-01-0003",
                  },
                  { "FENTRYID":3,
                    "FTYPE": "手环",
                    "FCATNO":"100001",
                    "FCATNAME": "智能手环",
                    "FBRAND": "标准",
                    "FSPEC":"500-D",
                    "FNUM":"SH25-01-0005",
                  },
                  { "FENTRYID":4,
                    "FTYPE": "摄像机",
                    "FCATNO":"100002",
                    "FCATNAME": "佩戴式摄像机",
                    "FBRAND": "标准",
                    "FSPEC":"700-L",
                    "FNUM":"XJ25-01-0005",
                  }],
        loading: false,
        visible: false,

        options1: [{
          value: '1',
          label: '日巡查'
        }, {
          value: '2',
          label: '月巡查'
        }, {
          value: '3',
          label: '年巡查'
        }],

        options2: [{
          value: '1',
          label: '未确认'
        }, {
          value: '2',
          label: '已确认'
        }, {
          value: '3',
          label: '已作废'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      closePage(){
        console.log('关闭弹窗dialog');
        this.visible = false;
      },
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>